//
//  PostViewController.m
//  XiangCaoJiaYuan
//
//  Created by tongj on 2017/8/23.
//  Copyright © 2017年 tongj. All rights reserved.
//

#import "PostViewController.h"
#import "UIButton+LT.h"
#import "DingERedViewController.h"//定额红包界面
#import "DaTiRedViewController.h"//答题红包界面
#import "JiangPinViewController.h"//发奖品界面
#import "XHDatePickerView.h"
#import "NSDate+XHExtension.h"
#import "HJCAjustNumButton.h"

@interface PostViewController ()<UIScrollViewDelegate,UITextFieldDelegate,UITextViewDelegate>
{
    UIScrollView* scroll;
    BaseTextFiled* NameFiled;//店铺名称
    BaseTextFiled* ThemeFiled;//活动主题
    BaseTextFiled* KtimeFiled;//开始时间
    UITextView* IntroduceTextView;//活动介绍
    UITextView* ActivityOneTextView;//商店促销1
    UITextView* ActivityTowTextView;//商店促销2
    UITextView* ActivityTherrTextView;//商店促销3
    
    UIButton* PostBut;
    UIButton *_selectButton;
    UIButton *_noselectButton;
    NSString *status;
    
    UIButton *_Ktime;
    UIButton *_Etime;
    NSString *_k;
    NSString *_e;
    
    UIImageView* ActiviOneImg;
    UIImageView* ActiviTowImg;
    UIImageView* ActiviThreeImg;
    
    UIView* ShareView;
    UIButton* DaRedbut;//答题红包选择框
    UIButton* DingEbut;//定额红包选择框
    UIImageView* Redimage;//红包选项框
    
    //商店优惠
    UITextField* pay1;//价格1
    UITextField* pay2;//价格2
    UITextField* pay3;//价格3
    
    HJCAjustNumButton *btn;
    HJCAjustNumButton *btn2;
    HJCAjustNumButton *btn3;
    
    //优惠券
    UITextField* youhuiM;
    UITextField* youhuiC;
    UITextView* youhuiT;
    //折扣券
    UITextField* zhekouM;
    UITextField* zhekouC;
    UITextView* zhekouT;
    
    NSString *_fabuzige;
    
    UIButton *button1;
    UIButton *button2;
    UIButton *button3;
    UIButton *button4;
    NSString *btnStatus1;
    NSString *btnStatus2;

}
@end

@implementation PostViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.title = @"发布信息";
    
    [UIButton backButton:self.navigationItem Col:self];
    [self createUI];
    self.view.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fingerTapped:)];
    
    [self.view addGestureRecognizer:singleTap];
    
  
}
-(void)viewWillAppear:(BOOL)animated{
    _fabuzige = [USERDEFAULT objectForKey:@"fabuzige"];
    if ([_fabuzige isEqualToString:@"0"]) {
        [PostBut setImage:[UIImage imageNamed:@"fabu_action"] forState:UIControlStateNormal];
    }else{
        [PostBut setImage:[UIImage imageNamed:@"发布活动"] forState:UIControlStateNormal];
    }
}
-(BOOL) textFieldShouldReturn:(UITextField *)textField {
    
    [textField resignFirstResponder];
    
    return YES;
    
}

-(void)fingerTapped:(UITapGestureRecognizer *)gestureRecognizer

{
    
    [self.view endEditing:YES];
    
}

-(void)createUI
{
    scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, UIScreen_WIDTH,UIScreen_HEIGHT-64)];
    
    UIImageView* image = [[UIImageView alloc]init];
    image.frame = CGRectMake(0, 0, UIScreen_WIDTH,1489*HEIGHT+(UIScreen_WIDTH-30)/4);
    image.userInteractionEnabled = YES;
    image.image = [UIImage imageNamed:@"发布活动页08-23"];
    
    scroll.contentSize = image.frame.size;
    scroll.scrollEnabled = YES;
    scroll.showsVerticalScrollIndicator = NO;
    scroll.showsHorizontalScrollIndicator = NO;
    scroll.bounces = NO;
    [self.view addSubview:scroll];
    [scroll addSubview:image];
    
    //店铺名称
    UILabel* NameLab = [[UILabel alloc]initWithFrame:CGRectMake(19*WIDTH, 13*HEIGHT, 200, 14)];
    NameLab.text = @"店铺名称";
    NameLab.font = [UIFont systemFontOfSize:14*WIDTH];
    [image addSubview:NameLab];
    
    NameFiled = [[BaseTextFiled alloc]initWithFrame:CGRectMake(11*WIDTH, 13*HEIGHT+NameLab.frame.size.height+9, UIScreen_WIDTH-2*11*WIDTH, 38*HEIGHT)];
    NameFiled.placeholder = @"店铺主题";
    NameFiled.delegate = self;
    NameFiled.borderStyle = UITextBorderStyleRoundedRect;
    [image addSubview:NameFiled];
    
    //活动主题
    UILabel* ThemeLab = [[UILabel alloc]initWithFrame:CGRectMake(19*WIDTH,13*HEIGHT+NameLab.frame.size.height+9+13*HEIGHT+NameFiled.frame.size.height, 200, 14)];
    ThemeLab.text = @"活动主题";
    ThemeLab.font = [UIFont systemFontOfSize:14*WIDTH];
    [image addSubview:ThemeLab];
    
    ThemeFiled = [[BaseTextFiled alloc]initWithFrame:CGRectMake(11*WIDTH, 13*HEIGHT+NameLab.frame.size.height+9+NameFiled.frame.size.height+13*HEIGHT+ThemeLab.frame.size.height+9, UIScreen_WIDTH-2*11*WIDTH, 38*HEIGHT)];
    ThemeFiled.placeholder = @"请添加此次活动的主题";
    [image addSubview:ThemeFiled];
    
    //活动时间选择
    UILabel* KtimeLab = [[UILabel alloc]initWithFrame:CGRectMake(19*WIDTH,13*HEIGHT+NameLab.frame.size.height+9+NameFiled.frame.size.height+13*HEIGHT+ThemeLab.frame.size.height+9+ThemeFiled.frame.size.height+13*HEIGHT, 200, 14*HEIGHT)];
    KtimeLab.text = @"活动时间";
    KtimeLab.font = [UIFont systemFontOfSize:14*WIDTH];
    [image addSubview:KtimeLab];
    KtimeFiled = [[BaseTextFiled alloc]initWithFrame:CGRectMake(11*WIDTH, 13*HEIGHT+NameLab.frame.size.height+9+NameFiled.frame.size.height+13*HEIGHT+ThemeLab.frame.size.height+9+ThemeFiled.frame.size.height+13*HEIGHT+9+KtimeLab.frame.size.height, UIScreen_WIDTH-2*11*WIDTH, 38*HEIGHT)];
    [image addSubview:KtimeFiled];
    
    _Ktime = [[UIButton alloc]initWithFrame:CGRectMake(10, 5, UIScreen_WIDTH-20, KtimeFiled.frame.size.height-10)
              ];
    [_Ktime setTitle:@"请选择活动时间" forState:UIControlStateNormal];
    [_Ktime setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    _Ktime.titleLabel.textAlignment = NSTextAlignmentCenter;
    [_Ktime addTarget:self action:@selector(ckickTime) forControlEvents:UIControlEventTouchUpInside];
    [KtimeFiled addSubview:_Ktime];
    
    //活动介绍
    UILabel* IntroduceLab = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH*19, 13*HEIGHT+NameLab.frame.size.height+NameFiled.frame.size.height+13*HEIGHT+ThemeLab.frame.size.height+13+ThemeFiled.frame.size.height+13*HEIGHT+ KtimeLab.frame.size.height+13*HEIGHT+KtimeFiled.frame.size.height+HEIGHT*13, 200, 14*WIDTH)];
    IntroduceLab.text = @"活动介绍";
    IntroduceLab.font = [UIFont systemFontOfSize:14*HEIGHT];
    [image addSubview:IntroduceLab];
    
    UIView* ViewD = [[UIView alloc]initWithFrame:CGRectMake(WIDTH*11, 13*HEIGHT+NameLab.frame.size.height+NameFiled.frame.size.height+13*HEIGHT+ThemeLab.frame.size.height+13+ThemeFiled.frame.size.height+13*HEIGHT+IntroduceLab.frame.size.height+KtimeLab.frame.size.height+13*HEIGHT+KtimeFiled.frame.size.height+9+HEIGHT*13, UIScreen_WIDTH-2*WIDTH*11, HEIGHT*125)];
    ViewD.layer.borderWidth = 3.0f;
    ViewD.backgroundColor = [UIColor whiteColor];
    ViewD.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    [image addSubview:ViewD];
    
    //创建输入框
    IntroduceTextView = [[UITextView alloc] init];
    IntroduceTextView.delegate = self;
    IntroduceTextView.frame = CGRectMake(10,5,ViewD.frame.size.width-10,ViewD.frame.size.height-10);
    //    textView.center = self.view.center;
    //    textView.text = @"请写在自定义属性前面，如果长度大于limitLength设置长度会被自动截断。";
    IntroduceTextView.placeholder = @"我们将根据您反馈的意见和问题, 提升产品的体验感!";
    IntroduceTextView.limitLength = @500;
    [ViewD addSubview:IntroduceTextView];
    
    //商店优惠，促销活动
    UILabel* ActivityLab= [[UILabel alloc]initWithFrame:CGRectMake(WIDTH*19, 13*HEIGHT+NameLab.frame.size.height+9+NameFiled.frame.size.height+13*HEIGHT+ThemeLab.frame.size.height+ThemeFiled.frame.size.height+13*HEIGHT+IntroduceLab.frame.size.height+ViewD.frame.size.height+13*HEIGHT+KtimeLab.frame.size.height+13*HEIGHT+KtimeFiled.frame.size.height+KtimeLab.frame.size.height+HEIGHT*13, 200, 14*WIDTH)];
    ActivityLab.text = @"商店优惠、促销活动";
    ActivityLab.font = [UIFont systemFontOfSize:14*HEIGHT];
    [image addSubview:ActivityLab];
    
    
    //第一个商品
    UIImageView* imgOne = [[UIImageView alloc]init];
    imgOne.userInteractionEnabled = YES;
    imgOne.frame =CGRectMake(11*WIDTH, 13*HEIGHT+NameLab.frame.size.height+NameFiled.frame.size.height+13*HEIGHT+ThemeLab.frame.size.height+ThemeFiled.frame.size.height+13*HEIGHT+IntroduceLab.frame.size.height+9+ViewD.frame.size.height+13*HEIGHT+ActivityLab.frame.size.height+KtimeLab.frame.size.height+13*HEIGHT+KtimeFiled.frame.size.height+KtimeLab.frame.size.height+9+HEIGHT*13, UIScreen_WIDTH-11*WIDTH*2, 150*HEIGHT);
    imgOne.image = [UIImage imageNamed:@"发布活动页08-23_12"];
    [image addSubview:imgOne];

    ActiviOneImg = [[UIImageView alloc]initWithFrame:CGRectMake(10*WIDTH, 12*HEIGHT, 100*WIDTH, 130*WIDTH)];
    ActiviOneImg.image = [UIImage imageNamed:@"发布活动页08-23_09"];
    [imgOne addSubview:ActiviOneImg];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-50, 14*HEIGHT, 40, 20*HEIGHT)];
    label.text = @"价格";
    [imgOne addSubview:label];
    pay1 = [[UITextField alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-10, 9*HEIGHT, UIScreen_WIDTH/2-20, 30*HEIGHT)];
    pay1.placeholder = @"请填写单品活动价格";
    pay1.keyboardType = UIKeyboardTypeDecimalPad;
    pay1.font = [UIFont systemFontOfSize:15];
    pay1.delegate = self;
    pay1.borderStyle = UITextBorderStyleRoundedRect;
    pay1.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    pay1.layer.borderWidth = 1;
    [imgOne addSubview:pay1];
    UILabel *count1 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-50, 50*HEIGHT, 40, 20*HEIGHT)];
    count1.text = @"数量";
    [imgOne addSubview:count1];
    btn = [[HJCAjustNumButton alloc] init];
    btn.frame = CGRectMake(UIScreen_WIDTH/2-10, 45*HEIGHT, UIScreen_WIDTH/2-20, 30*HEIGHT);
    [imgOne addSubview:btn];
    btn.callBack = ^(NSString *currentNum){
        NSLog(@"btn===%@", currentNum);
    };
    UILabel *miao1 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-50, 85*HEIGHT, 40, 20*HEIGHT)];
    miao1.text = @"描述";
    [imgOne addSubview:miao1];
    //创建输入框
    ActivityOneTextView = [[UITextView alloc] init];
    ActivityOneTextView.delegate = self;
    ActivityOneTextView.frame = CGRectMake(UIScreen_WIDTH/2-10,80*HEIGHT, UIScreen_WIDTH/2-20,60*HEIGHT);
    //    textView.center = self.view.center;
    //    textView.text = @"请写在自定义属性前面，如果长度大于limitLength设置长度会被自动截断。";
    ActivityOneTextView.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    ActivityOneTextView.layer.borderWidth = 1;
    ActivityOneTextView.font = [UIFont systemFontOfSize:14];
    ActivityOneTextView.placeholder = @"宣传店铺特色介绍，推出店铺优惠活动等~";
    ActivityOneTextView.limitLength = @30;
    [imgOne addSubview:ActivityOneTextView];
    
    
    //第二个商品
    UIImageView* imgTow = [[UIImageView alloc]initWithFrame:CGRectMake(11*WIDTH, 13*HEIGHT+NameLab.frame.size.height+9+NameFiled.frame.size.height+13*HEIGHT+ThemeLab.frame.size.height+ThemeFiled.frame.size.height+13*HEIGHT+IntroduceLab.frame.size.height+ViewD.frame.size.height+13*HEIGHT+ActivityLab.frame.size.height+12*HEIGHT+imgOne.frame.size.height+KtimeLab.frame.size.height+13*HEIGHT+KtimeFiled.frame.size.height+KtimeLab.frame.size.height+9+HEIGHT*13, UIScreen_WIDTH-11*WIDTH*2, 150*HEIGHT)];
    imgTow.image = [UIImage imageNamed:@"发布活动页08-23_12"];
    [image addSubview:imgTow];
    imgTow.userInteractionEnabled = YES;
    
    ActiviTowImg = [[UIImageView alloc]initWithFrame:CGRectMake(10*WIDTH, 12*HEIGHT, 100*WIDTH,130*WIDTH)];
    ActiviTowImg.image = [UIImage imageNamed:@"发布活动页08-23_09"];
    [imgTow addSubview:ActiviTowImg];
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-50, 14*HEIGHT, 40, 20*HEIGHT)];
    label2.text = @"价格";
    [imgTow addSubview:label2];
    pay2 = [[UITextField alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-10, 9*HEIGHT, UIScreen_WIDTH/2-20, 30*HEIGHT)];
    pay2.placeholder = @"请填写单品活动价格";
    pay2.font = [UIFont systemFontOfSize:15];
    pay2.delegate = self;
    pay2.borderStyle = UITextBorderStyleRoundedRect;
    pay2.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    pay2.layer.borderWidth = 1;
    [imgTow addSubview:pay2];
    UILabel *count2 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-50, 50*HEIGHT, 40, 20*HEIGHT)];
    count2.text = @"数量";
    [imgTow addSubview:count2];
    btn2 = [[HJCAjustNumButton alloc] init];
    btn2.frame = CGRectMake(UIScreen_WIDTH/2-10, 45*HEIGHT, UIScreen_WIDTH/2-20, 30*HEIGHT);
    [imgTow addSubview:btn2];
    btn2.callBack = ^(NSString *currentNum){
        NSLog(@"btn===%@", currentNum);
    };
    UILabel *miao2 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-50, 85*HEIGHT, 40, 20*HEIGHT)];
    miao2.text = @"描述";
    [imgTow addSubview:miao2];
    //创建输入框
    ActivityTowTextView = [[UITextView alloc] init];
    ActivityTowTextView.delegate = self;
    ActivityTowTextView.frame = CGRectMake(UIScreen_WIDTH/2-10,80*HEIGHT, UIScreen_WIDTH/2-20,60*HEIGHT);
    ActivityTowTextView.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    ActivityTowTextView.layer.borderWidth = 1;
    ActivityTowTextView.font = [UIFont systemFontOfSize:14];
    ActivityTowTextView.placeholder = @"宣传店铺特色介绍，推出店铺优惠活动等~";
    ActivityTowTextView.limitLength = @30;
    [imgTow addSubview:ActivityTowTextView];

    //第三个商品
    UIImageView* imgThree = [[UIImageView alloc]initWithFrame:CGRectMake(11*WIDTH, 13*HEIGHT+NameLab.frame.size.height+9+NameFiled.frame.size.height+13*HEIGHT+ThemeLab.frame.size.height+ThemeFiled.frame.size.height+13*HEIGHT+IntroduceLab.frame.size.height+ViewD.frame.size.height+13*HEIGHT+ActivityLab.frame.size.height+12*HEIGHT+imgOne.frame.size.height+12*HEIGHT+imgOne.frame.size.height+KtimeLab.frame.size.height+13*HEIGHT+KtimeFiled.frame.size.height+KtimeLab.frame.size.height+9+HEIGHT*13, UIScreen_WIDTH-11*WIDTH*2, 150*HEIGHT)];
    imgThree.image = [UIImage imageNamed:@"发布活动页08-23_12"];
    [image addSubview:imgThree];
    imgThree.userInteractionEnabled = YES;
    
    ActiviThreeImg = [[UIImageView alloc]initWithFrame:CGRectMake(10*WIDTH, 12*HEIGHT, 100*WIDTH, 130*WIDTH)];
    ActiviThreeImg.image = [UIImage imageNamed:@"发布活动页08-23_09"];
    [imgThree addSubview:ActiviThreeImg];
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-50, 14*HEIGHT, 40, 20*HEIGHT)];
    label3.text = @"价格";
    [imgThree addSubview:label3];

    pay3 = [[UITextField alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-10, 9*HEIGHT, UIScreen_WIDTH/2-20, 30*HEIGHT)];
    pay3.placeholder = @"请填写单品活动价格";
    pay3.font = [UIFont systemFontOfSize:15];
    pay3.delegate = self;
    pay3.borderStyle = UITextBorderStyleRoundedRect;
    pay3.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    pay3.layer.borderWidth = 1;
    [imgThree addSubview:pay3];
    UILabel *count3 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-50, 50*HEIGHT, 40, 20*HEIGHT)];
    count3.text = @"数量";
    [imgThree addSubview:count3];
    btn3 = [[HJCAjustNumButton alloc] init];
    btn3.frame = CGRectMake(UIScreen_WIDTH/2-10, 45*HEIGHT, UIScreen_WIDTH/2-20, 30*HEIGHT);
    [imgThree addSubview:btn3];
    btn3.callBack = ^(NSString *currentNum){
        NSLog(@"btn===%@", currentNum);
    };
    UILabel *miao3 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-50, 85*HEIGHT, 40, 20*HEIGHT)];
    miao3.text = @"描述";
    [imgThree addSubview:miao3];
    //创建输入框
    ActivityTherrTextView = [[UITextView alloc] init];
    ActivityTherrTextView.delegate = self;
    ActivityTherrTextView.frame = CGRectMake(UIScreen_WIDTH/2-10,80*HEIGHT, UIScreen_WIDTH/2-20,60*HEIGHT);
    ActivityTherrTextView.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    ActivityTherrTextView.layer.borderWidth = 1;
    
    ActivityTherrTextView.font = [UIFont systemFontOfSize:14];
    ActivityTherrTextView.placeholder = @"宣传店铺特色介绍，推出店铺优惠活动等~";
    ActivityTherrTextView.limitLength = @30;
    [imgThree addSubview:ActivityTherrTextView];
    
    //优惠券模块
    UILabel* youhui = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH*19, imgThree.frame.origin.y+imgThree.frame.size.height+10, 200, 14*WIDTH)];
    youhui.text = @"优惠券(选填)";
    youhui.font = [UIFont systemFontOfSize:14*HEIGHT];
    [image addSubview:youhui];
    UIImageView* imgfour = [[UIImageView alloc]initWithFrame:CGRectMake(11*WIDTH, youhui.frame.origin.y+24+HEIGHT, UIScreen_WIDTH-11*WIDTH*2, 130*HEIGHT)];
    imgfour.image = [UIImage imageNamed:@"发布活动页08-23_12"];
    [image addSubview:imgfour];
    imgfour.userInteractionEnabled = YES;
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(10, 20*HEIGHT, 70, 20*HEIGHT)];
    label5.text = @"优惠金额";
    [imgfour addSubview:label5];
    youhuiM = [[UITextField alloc]initWithFrame:CGRectMake(90*WIDTH, 15*HEIGHT, 90*WIDTH, 30*HEIGHT)];
    youhuiM.placeholder = @"优惠数额";
    youhuiM.font = [UIFont systemFontOfSize:15];
    youhuiM.delegate = self;
    youhuiM.keyboardType = UIKeyboardTypeDecimalPad;
    youhuiM.borderStyle = UITextBorderStyleRoundedRect;
    youhuiM.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    youhuiM.layer.borderWidth = 1;
    [imgfour addSubview:youhuiM];
    UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(200*WIDTH, 20*HEIGHT, 70*WIDTH, 20*HEIGHT)];
    label6.text = @"数量";
    [imgfour addSubview:label6];
    youhuiC = [[UITextField alloc]initWithFrame:CGRectMake(245*WIDTH, 15*HEIGHT, 90*WIDTH, 30*HEIGHT)];
    youhuiC.placeholder = @"优惠数量";
    youhuiC.font = [UIFont systemFontOfSize:15];
    youhuiC.delegate = self;
    youhuiC.keyboardType = UIKeyboardTypeDecimalPad;
    youhuiC.borderStyle = UITextBorderStyleRoundedRect;
    youhuiC.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    youhuiC.layer.borderWidth = 1;
    [imgfour addSubview:youhuiC];
    UILabel *label7 = [[UILabel alloc]initWithFrame:CGRectMake(10*WIDTH, 60*HEIGHT, 70*WIDTH, 20*HEIGHT)];
    label7.text = @"优惠主题";
    [imgfour addSubview:label7];
    youhuiT = [[UITextView alloc]initWithFrame:CGRectMake(90*WIDTH, 55*HEIGHT, UIScreen_WIDTH-120*WIDTH, 30*HEIGHT)];
    youhuiT.placeholder = @"请填写优惠活动主题";
    youhuiT.font = [UIFont systemFontOfSize:15];
    youhuiT.delegate = self;
    youhuiT.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    youhuiT.layer.borderWidth = 1;
    youhuiT.limitLength = @10;
    [imgfour addSubview:youhuiT];
    button1 = [[UIButton alloc]initWithFrame:CGRectMake(20*WIDTH,93*HEIGHT , 140*WIDTH, 30*HEIGHT)];
    [button1 setImage:[UIImage imageNamed:@"youhui_btn_sel"] forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(clickbtn1) forControlEvents:UIControlEventTouchUpInside];
    [imgfour addSubview:button1];
    btnStatus1 = @"1";
    button2 = [[UIButton alloc]initWithFrame:CGRectMake(197*WIDTH,93*HEIGHT , 140*WIDTH, 30*HEIGHT)];
    [button2 addTarget:self action:@selector(clickbtn2) forControlEvents:UIControlEventTouchUpInside];
    [button2 setImage:[UIImage imageNamed:@"youhuipart_btn_nor"] forState:UIControlStateNormal];
    [imgfour addSubview:button2];

    //折扣券模块
    UILabel* zhekou = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH*19, imgfour.frame.origin.y+imgfour.frame.size.height+10, 200, 14*WIDTH)];
    zhekou.text = @"折扣券(选填)";
    zhekou.font = [UIFont systemFontOfSize:14*HEIGHT];
    [image addSubview:zhekou];
    UIImageView* imgfive = [[UIImageView alloc]initWithFrame:CGRectMake(11*WIDTH, zhekou.frame.origin.y+24+HEIGHT, UIScreen_WIDTH-11*WIDTH*2, 130*HEIGHT)];
    imgfive.image = [UIImage imageNamed:@"发布活动页08-23_12"];
    [image addSubview:imgfive];
    imgfive.userInteractionEnabled = YES;
    UILabel *label8 = [[UILabel alloc]initWithFrame:CGRectMake(10, 20*HEIGHT, 70, 20*HEIGHT)];
    label8.text = @"折扣率";
    [imgfive addSubview:label8];
    zhekouM = [[UITextField alloc]initWithFrame:CGRectMake(90*WIDTH, 15*HEIGHT, 90*WIDTH, 30*HEIGHT)];
    zhekouM.placeholder = @"0<折扣<1";
    zhekouM.font = [UIFont systemFontOfSize:15];
    zhekouM.delegate = self;
    zhekouM.keyboardType = UIKeyboardTypeDecimalPad;
    zhekouM.borderStyle = UITextBorderStyleRoundedRect;
    zhekouM.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    zhekouM.layer.borderWidth = 1;
    [imgfive addSubview:zhekouM];
    UILabel *label9 = [[UILabel alloc]initWithFrame:CGRectMake(200*WIDTH, 20*HEIGHT, 70*WIDTH, 20*HEIGHT)];
    label9.text = @"数量";
    [imgfive addSubview:label9];
    zhekouC = [[UITextField alloc]initWithFrame:CGRectMake(245*WIDTH, 15*HEIGHT, 90*WIDTH, 30*HEIGHT)];
    zhekouC.placeholder = @"折扣数量";
    zhekouC.font = [UIFont systemFontOfSize:15];
    zhekouC.delegate = self;
    zhekouC.keyboardType = UIKeyboardTypeDecimalPad;
    zhekouC.borderStyle = UITextBorderStyleRoundedRect;
    zhekouC.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    zhekouC.layer.borderWidth = 1;
    [imgfive addSubview:zhekouC];
    UILabel *label10 = [[UILabel alloc]initWithFrame:CGRectMake(10*WIDTH, 60*HEIGHT, 70*WIDTH, 20*HEIGHT)];
    label10.text = @"折扣主题";
    [imgfive addSubview:label10];
    zhekouT = [[UITextView alloc]initWithFrame:CGRectMake(90*WIDTH, 55*HEIGHT, UIScreen_WIDTH-120*WIDTH, 30*HEIGHT)];
    zhekouT.placeholder = @"请填写折扣活动主题";
    zhekouT.font = [UIFont systemFontOfSize:15];
    zhekouT.delegate = self;
    zhekouT.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    zhekouT.layer.borderWidth = 1;
    zhekouT.limitLength = @10;
    [imgfive addSubview:zhekouT];
    button3 = [[UIButton alloc]initWithFrame:CGRectMake(20*WIDTH,93*HEIGHT , 140*WIDTH, 30*HEIGHT)];
    [button3 addTarget:self action:@selector(clickbtn3) forControlEvents:UIControlEventTouchUpInside];
    [button3 setImage:[UIImage imageNamed:@"zhekou_btn_sel"] forState:UIControlStateNormal];
    [imgfive addSubview:button3];
    btnStatus2 = @"1";
    button4 = [[UIButton alloc]initWithFrame:CGRectMake(197*WIDTH,93*HEIGHT , 140*WIDTH, 30*HEIGHT)];
    [button4 setImage:[UIImage imageNamed:@"zhekoupart_btn_nor"] forState:UIControlStateNormal];
    [button4 addTarget:self action:@selector(clickbtn4) forControlEvents:UIControlEventTouchUpInside];
    [imgfive addSubview:button4];
    //备注
    UILabel* beizhu = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH*19, imgfive.frame.origin.y+imgfive.frame.size.height+10, 200, 14*WIDTH)];
    beizhu.text = @"备注";
    beizhu.font = [UIFont systemFontOfSize:14*HEIGHT];
    [image addSubview:beizhu];

    UIView* ViewE = [[UIView alloc]initWithFrame:CGRectMake(WIDTH*11, beizhu.frame.origin.y+beizhu.frame.size.height+13, UIScreen_WIDTH-2*WIDTH*11, HEIGHT*125)];
    ViewE.layer.borderWidth = 3.0f;
    ViewE.backgroundColor = [UIColor whiteColor];
    ViewE.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    [image addSubview:ViewE];
//
//    //创建输入框
    IntroduceTextView = [[UITextView alloc] init];
    IntroduceTextView.delegate = self;
    IntroduceTextView.frame = CGRectMake(10,5,ViewD.frame.size.width-10,ViewD.frame.size.height-10);
    //    textView.center = self.view.center;
    //    textView.text = @"请写在自定义属性前面，如果长度大于limitLength设置长度会被自动截断。";
    IntroduceTextView.placeholder = @"商家促销活动，如：包含配送活动的，请在活动价格上加上3km的配送费。";
    IntroduceTextView.limitLength = @100;
    [ViewE addSubview:IntroduceTextView];
    
    
    // 发红包以及发奖品的按钮
//    fa_hognbao  fa_jiangping
    NSArray* arr =@[@"发红包",@"发抽奖"];
    for (int i =0; i<arr.count; i++) {
        
        UIButton* FaBut = [UIButton buttonWithType:UIButtonTypeCustom];
        FaBut.tag = i+1;
        FaBut.frame = CGRectMake(((UIScreen_WIDTH-30)/2+10)*i+10,ViewE.frame.origin.y+ViewE.frame.size.height+20, (UIScreen_WIDTH-30)/2,(UIScreen_WIDTH-30)/3.5);
        [FaBut setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",arr[i]]] forState:UIControlStateNormal];
        [FaBut addTarget:self action:@selector(FaClick:) forControlEvents:UIControlEventTouchUpInside];
        [image addSubview:FaBut];
        
    }
    //发布按钮
    PostBut = [UIButton buttonWithType:UIButtonTypeCustom];
    PostBut.frame = CGRectMake(WIDTH*11, ViewE.frame.origin.y+ViewE.frame.size.height+60+(UIScreen_WIDTH-30)/4, UIScreen_WIDTH-2*WIDTH*11, 41*HEIGHT);

    [PostBut addTarget:self action:@selector(PostClick) forControlEvents:UIControlEventTouchUpInside];
    [image addSubview:PostBut];

    
}
-(void)clickbtn1{
    btnStatus1 = @"1";
    [button1 setImage:[UIImage imageNamed:@"youhui_btn_sel"] forState:UIControlStateNormal];
    [button2 setImage:[UIImage imageNamed:@"youhuipart_btn_nor"] forState:UIControlStateNormal];

}
-(void)clickbtn2{
    btnStatus1 = @"2";
    [button1 setImage:[UIImage imageNamed:@"youhui_btn_nor"] forState:UIControlStateNormal];
    [button2 setImage:[UIImage imageNamed:@"youhuipart_btn_sel"] forState:UIControlStateNormal];
}
-(void)clickbtn3{
    btnStatus2 = @"1";
    [button3 setImage:[UIImage imageNamed:@"zhekou_btn_sel"] forState:UIControlStateNormal];
    [button4 setImage:[UIImage imageNamed:@"zhekoupart_btn_nor"] forState:UIControlStateNormal];
}
-(void)clickbtn4{
    btnStatus2 = @"2";
    [button3 setImage:[UIImage imageNamed:@"zhekou_btn_nor"] forState:UIControlStateNormal];
    [button4 setImage:[UIImage imageNamed:@"zhekoupart_btn_sel"] forState:UIControlStateNormal];

}
-(void)ckickTime{
    
    XHDatePickerView *datepicker = [[XHDatePickerView alloc] initWithCurrentDate:[NSDate date] CompleteBlock:^(NSDate *startDate, NSDate *endDate) {
        NSString *format;
        format = @"yyyy-MM-dd";
        NSLog(@"\n开始时间： %@，结束时间：%@",startDate,endDate);
        if (startDate) {
            _k = [startDate stringWithFormat:format];
        }
        
        if (endDate) {
             _e = [endDate stringWithFormat:format];
        }
  
        [_Ktime setTitle:[NSString stringWithFormat:@"%@ 至 %@",_k,_e] forState:UIControlStateNormal];
        
    }];
    datepicker.datePickerStyle = DateStyleShowYearMonthDay;
    datepicker.dateType = DateTypeStartDate;
    datepicker.minLimitDate = [NSDate date:@"2017-2-28 12:22" WithFormat:@"yyyy-MM-dd"];
    datepicker.maxLimitDate = [NSDate date:@"2018-2-28 12:12" WithFormat:@"yyyy-MM-dd"];
    [datepicker show];
    
}
#pragma mark 发布按钮
-(void)PostClick
{
    if ([_fabuzige isEqualToString:@"0"]) {
    }else{
        [self.view makeToast:@"请通过发红包或者抽奖获取发布活动资格"];
    }
    NSLog(@"发布按钮");
}
#pragma mark 发包按钮
-(void)FaClick:(UIButton*)sender
{
    if (sender.tag==1) {
        
        [self ClassView];
        NSLog(@"发红包");
    }
    else
    {
        JiangPinViewController* JiangPinVC = [[JiangPinViewController alloc]init];
        [self.navigationController pushViewController:JiangPinVC animated:NO];
        NSLog(@"发奖品");
    }
    
}
-(void)ClassView{
    
    ShareView = [[UIView alloc]initWithFrame:CGRectMake(0, 0,UIScreen_WIDTH,UIScreen_HEIGHT)];
    ShareView.backgroundColor = UIColorFromRGBA(0x000000, 0.8);
    [[UIApplication sharedApplication].keyWindow addSubview:ShareView];
    [self RedBaoLeiXing];
}
-(void)RedBaoLeiXing
{
    status = @"1";
    Redimage = [[UIImageView alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/6, 50*HEIGHT,UIScreen_WIDTH*2/3, UIScreen_WIDTH*3/4)];
    Redimage.userInteractionEnabled = YES;
    Redimage.image = [UIImage imageNamed:@"未标题-5"];
    [ShareView addSubview:Redimage];

    
//    
    DaRedbut= [[UIButton alloc]initWithFrame:CGRectMake(17,140*HEIGHT,UIScreen_WIDTH*2/3-40, UIScreen_WIDTH/5)];
    [DaRedbut setImage:[UIImage imageNamed:@"未标题-6"] forState:UIControlStateNormal];
//    [DaRedbut addTarget:self action:@selector(DaRedClick:) forControlEvents:UIControlEventTouchUpInside];
    [Redimage addSubview:DaRedbut];
    
    _selectButton = [[UIButton alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/6+17, 210*HEIGHT+ UIScreen_WIDTH/5, 20*HEIGHT, 20*HEIGHT)];
    if ([status isEqualToString:@"1"]) {
        [_selectButton setImage:[UIImage imageNamed:@"打钩"] forState:UIControlStateNormal];
 
    }else{
        [_selectButton setImage:[UIImage imageNamed:@"未打钩"] forState:UIControlStateNormal];

    }
    [_selectButton addTarget:self action:@selector(clickS) forControlEvents:UIControlEventTouchUpInside];
    [ShareView addSubview:_selectButton];
    UILabel *la1 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/6+17+20*HEIGHT+10, 210*HEIGHT+ UIScreen_WIDTH/5, 70, 20)];
    la1.text = @"普通红包";
    [ShareView addSubview:la1];
    UILabel *la2 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2+20*HEIGHT+10, 210*HEIGHT+ UIScreen_WIDTH/5, 70, 20)];
    la2.text = @"高级红包";
    [ShareView addSubview:la2];
    
    _noselectButton = [[UIButton alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2, 210*HEIGHT+ UIScreen_WIDTH/5, 20*HEIGHT, 20*HEIGHT)];
    if ([status isEqualToString:@"2"]) {
        [_noselectButton setImage:[UIImage imageNamed:@"打钩"] forState:UIControlStateNormal];
        
    }else{
        [_noselectButton setImage:[UIImage imageNamed:@"未打钩"] forState:UIControlStateNormal];
        
    }
    [_noselectButton addTarget:self action:@selector(clickS2) forControlEvents:UIControlEventTouchUpInside];

    [ShareView addSubview:_noselectButton];
//
    DingEbut= [UIButton buttonWithType:UIButtonTypeCustom];
    DingEbut.frame = CGRectMake(UIScreen_WIDTH/6-2,UIScreen_HEIGHT/2+10, UIScreen_WIDTH*2/3,40*HEIGHT);
    [DingEbut setImage:[UIImage imageNamed:@"未标题-8"] forState:UIControlStateNormal];
    [DingEbut addTarget:self action:@selector(DingEBut:) forControlEvents:UIControlEventTouchUpInside];
    [ShareView addSubview:DingEbut];
    
    UIImageView *im = [[UIImageView alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/6, UIScreen_HEIGHT/2+65,  UIScreen_WIDTH*2/3,  UIScreen_WIDTH*2.5/9)];
    im.image = [UIImage imageNamed:@"未标题-7"];
    [ShareView addSubview:im];
    
    
}
-(void)clickS{
    status = @"1";
    [_selectButton setImage:[UIImage imageNamed:@"打钩"] forState:UIControlStateNormal];
    [_noselectButton setImage:[UIImage imageNamed:@"未打钩"] forState:UIControlStateNormal];

}
-(void)clickS2{
    status = @"2";
    [_selectButton setImage:[UIImage imageNamed:@"未打钩"] forState:UIControlStateNormal];
    [_noselectButton setImage:[UIImage imageNamed:@"打钩"] forState:UIControlStateNormal];

}
-(void)DaRedClick:(UIButton*)sender
{
//    if (DaRedbut.selected) {
//        return;
//    }
//    DaRedbut.selected = YES;
//    DingEbut.selected = NO;
//    [DaRedbut setImage:[UIImage imageNamed:@"红包选择类型_03"] forState:UIControlStateNormal];
//    [DingEbut setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
//    ShareView.hidden = YES;
//    DaTiRedViewController* DaTiVC = [[DaTiRedViewController alloc]init];
//    [self.navigationController pushViewController:DaTiVC animated:NO];

}
-(void)DingEBut:(UIButton*)sender
{
    if (DingEbut.selected) {
        return;
    }
    DingEbut.selected = YES;
    DaRedbut.selected = NO;
    [DingEbut setImage:[UIImage imageNamed:@"红包选择类型_03"] forState:UIControlStateNormal];
    [DaRedbut setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    
    DingERedViewController* DingEVC = [[DingERedViewController alloc]init];
    ShareView.hidden = YES;
    DingEVC.status = status;
    [self.navigationController pushViewController:DingEVC animated:NO];
}



-(void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
